package com.alongthink.javademo.utilTools;

import ch.qos.logback.classic.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

/**
 * @Auther: along
 * @Date: 2019/4/8 14:15
 * @Description: 自定义日志输出，用于存储用户的操作记录
 */
public abstract class LoggerUtils {
    private static final Logger log = (Logger) LoggerFactory.getLogger("usr-op");
    private String time;
//    private String uid;
//    private String user;
//    private String ip;
//    private String front;//是否前台操作
    private String issuccess;//是否成功
    private String url;//操作的方法
    private String agument;//操作的参数
    private String detail;//操作内容详情
    private String msg;//操作消息
    private String runtime;//执行时间

    private LoggerUtils() {
    }

    public static Logger getLog() {
        return log;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getIssuccess() {
        return issuccess;
    }

    public void setIssuccess(String issuccess) {
        this.issuccess = issuccess;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getAgument() {
        return agument;
    }

    public void setAgument(String agument) {
        this.agument = agument;
    }

    public String getRuntime() {
        return runtime;
    }

    public void setRuntime(String runtime) {
        this.runtime = runtime;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public static void info(String time, String issuccess, String url, String agument, String detail, String msg, String runtime) {
        MDC.put("time", time);
        MDC.put("issuccess",issuccess);
        MDC.put("detail", detail);
        MDC.put("msg", msg);
        MDC.put("url",url);
        MDC.put("agument",agument);
        MDC.put("runtime",runtime);
        log.info("");
    }

}
